<extend name="layout/application"/>
<block name="content">
    <div class="admin-content">
        <div class="am-cf am-padding">
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">课程列表</strong> /
                <small>Course List</small>
            </div>
        </div>
        <div class="am-g">
            <div class="am-u-sm-12 am-u-md-12">
                <div class="am-btn-toolbar">
                    <div class="am-btn-group am-btn-group-xs">
                        <a type="button" class="am-btn am-btn-default" href="/admin/courses/create">
                            <span class="am-icon-plus"></span> 新增
                        </a>
                    </div>
                </div>
            </div>
        </div>

        <div class="am-g" style="margin-left: 55%">
            <div class="am-u-sm-12 am-u-md-12">
                <form class="am-form-inline" role="form" method="get">

                    <div class="am-form-group">
                        <input type="text" name="name" class="am-form-field am-input-sm" placeholder="课程名">
                    </div>
                    <button type="submit" class="am-btn am-btn-default am-btn-sm">查询</button>
                    <a href="#" class="am-btn am-btn-default am-btn-sm" type="button">重置</a>
                </form>
            </div>
        </div>
        <div class="am-g">
            <div class="am-u-sm-12">
                <form class="am-form">
                    <table class="am-table  am-table-hover table-main">
                        <thead>
                        <tr>
                            <th class="table-id">编号</th>
                            <th class="table-thumb">略缩图</th>
                            <th class="table-name">名称</th>
                            <th class="table-name">价格</th>
                            <th class="table-name">标签</th>
                            <th class="table-name">喜欢</th>
                            <th class="table-name">推荐</th>
                            <th class="table-name">发布</th>
                            <th class="table-name">完结</th>
                            <th>日期</th>
                            <th class="table-set">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <foreach $courses as $course>
                            <tr>
                                <td>{{$course.id}}</td>
                                <td>
                                    <img src="{{$course.photo.image}}" style="width:60px;height:50px;">
                                </td>
                                <td>{{$course.name}}
                                    <span class="am-badge am-badge-secondary  am-round ">全{{$course.chapters_count}}回</span>
                                </td>
                                <td>
                                    <if $course.price==0>
                                        <span class="am-badge am-badge-secondary am-radius ">免费</span>
                                        <else/>
                                        <span class="am-badge am-badge-secondary am-radius ">￥{{$course.price}}元</span>
                                    </if>
                                </td>
                                <td>
                                    <foreach $course.tags as $tag>
                                        <span class="am-badge am-badge-success  am-radius ">{{$tag.name}}</span>
                                    </foreach>
                                </td>

                                <td>
                                    <if $course.likes_count!=0>

                                        <span class="am-badge am-badge-danger am-round">{{$course.likes_count}}</span>
                                    </if>
                                </td>
                                <td>
                                    <if $course.best==0>
                                        <span class="am-badge am-badge-warning am-round ">推荐</span>
                                    </if>
                                </td>
                                <td>
                                    <if $course.publish==0>
                                        <span class="am-badge am-badge-danger  am-round ">待发布</span>
                                    </if>
                                </td>
                                <td>
                                    <if $course.complete==0>
                                        <span class="am-badge am-badge-success am-round ">更新中</span>
                                    </if>
                                </td>
                                <td>{{$course.created_at}}</td>
                                <td>
                                    <div class="am-btn-toolbar">
                                        <div class="am-btn-group am-btn-group-xs">
                                            <a class="am-btn am-btn-default am-btn-xs am-text-secondary"
                                               href="{{:Url('Courses/edit',['id'=>$course.id])}}">
                                                <span class="am-icon-pencil-square-o"></span> 编辑
                                            </a>

                                            <a class="am-btn am-btn-default am-btn-xs delete_category am-text-danger am-hide-sm-only"
                                               href="{{:Url('Courses/delete',['id'=>$course.id])}}">
                                                <span class="am-icon-trash-o"></span> 删除
                                            </a>
                                            <a class="am-btn am-btn-default am-btn-xs delete_category am-text-danger am-hide-sm-only"
                                               href="{{:Url('Chapters/read',['id'=>$course.id])}}">
                                                <span class="am-icon-file-text-o"></span> 内容
                                            </a>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </foreach>
                        </tbody>
                    </table>
                </form>
                <div class="am-cf">
                    共{{:count($courses)}}条记录
                    <div class="am-fr">
                        <ul class="am-pagination">
                            {{$courses|raw}}
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</block>
